package com.agv.core.dao.catalogosImpl;

import org.springframework.dao.DataAccessException;
import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.jdbc.core.support.JdbcDaoSupport;

import com.agv.core.dao.catalogos.TerminoPagoDAO;
import com.agv.core.dao.exception.QueryDAOException;
import com.agv.core.dao.mapper.TerminoPagoMapper;
import com.agv.dto.TerminoPagoDTO;

public class TerminoPagoDAOImpl extends JdbcDaoSupport implements TerminoPagoDAO{
	
	public Integer getTerminoPagoIdCliente( Integer idCliente) throws QueryDAOException {
		try {
						
			return(Integer) getJdbcTemplate().queryForObject(
					CONSULTA_TERMINOPAGO, new Object[] { idCliente },
					Integer.class);
		} catch (EmptyResultDataAccessException erdae) {
			return null;
		
		} catch (DataAccessException dae) {
			throw new QueryDAOException("Error termino pago", dae);
		}
	}
	final String CONSULTA_TERMINOPAGO =
		"select ctp.id_term_pago from cxc.t001_cxc_cfg_clientes ccc, cxc.t002_cxc_cfg_clientes ccc2,"+
		"cxc.t001_cxc_cfg_term_pago ctp where ccc.id_cte=ccc2.id_cte"+
		" and ccc2.id_term_pago=ctp.id_term_pago and ccc.id_cte= ? ";
	
}
